package com.whu.UVAProtocol;

import com.whu.aircraft.Aircraft;
import io.netty.channel.Channel;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * @Description "管理一个无人机连接状态"
 * @Author chengeng
 * @Date 2021/12/1 11:04
 **/
public class UVAConnection {
    private String UUID;
    private Aircraft aircraft;
    private char serialNum = 0;
    private List<byte[]> msgCache = new ArrayList<>(512);
    private Double picLongitude;
    private Double picLatitude;
    private Integer picDetect;
    private Channel channel;
    private LinkedBlockingDeque<String> picMsgQueue;
    private ArrayList<ArrayList<String>> picIllegalBuildingsPairs;
    private LocalDateTime expiredTime;//连接过期时间
    private int timeoutCnt = 0;

    public void timeoutCntIncrease(){
        this.timeoutCnt++;
    }
    public int getTimeoutCnt() {
        return timeoutCnt;
    }

    public void setTimeoutCnt(int timeoutCnt) {
        this.timeoutCnt = timeoutCnt;
    }

    public LocalDateTime getExpiredTime() {
        return expiredTime;
    }

    public void setExpiredTime(LocalDateTime expiredTime) {
        this.expiredTime = expiredTime;
    }

    public UVAConnection() {
        this.picMsgQueue = new LinkedBlockingDeque<>();
        this.picIllegalBuildingsPairs = new ArrayList<>();
    }


    public String getUUID() {
        return UUID;
    }

    public void setUUID(String UUID) {
        this.UUID = UUID;
    }

    public Double getPicLongitude() {
        return picLongitude;
    }

    public void setPicLongitude(Double picLongitude) {
        this.picLongitude = picLongitude;
    }

    public Double getPicLatitude() {
        return picLatitude;
    }

    public void setPicLatitude(Double picLatitude) {
        this.picLatitude = picLatitude;
    }

    public Integer getPicDetect() {
        return picDetect;
    }

    public void setPicDetect(Integer picDetect) {
        this.picDetect = picDetect;
    }

    public LinkedBlockingDeque<String> getPicMsgQueue() {
        return picMsgQueue;
    }

    public void setPicMsgQueue(LinkedBlockingDeque<String> picMsgQueue) {
        this.picMsgQueue = picMsgQueue;
    }

    public Aircraft getAircraft() {
        return aircraft;
    }

    public void setAircraft(Aircraft aircraft) {
        this.aircraft = aircraft;
    }

    public char getSerialNum() {
        return serialNum++;
    }
    public char getSerialNumForDIV(){
        return serialNum;
    }

    public List<byte[]> getMsgCache() {
        return msgCache;
    }

    public void setMsgCache(List<byte[]> msgCache) {
        this.msgCache = msgCache;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public ArrayList<ArrayList<String>> getPicIllegalBuildingsPairs() {
        return picIllegalBuildingsPairs;
    }

    public void setPicIllegalBuildingsPairs(ArrayList<ArrayList<String>> picIllegalBuildingsPairs) {
        this.picIllegalBuildingsPairs = picIllegalBuildingsPairs;
    }
}
